<template>
  <div class="home">
    <div class="header">
      <h3 class="user-name">笑笑</h3>
      <p class="words">Nothing Is Impossible!</p>
      <ul class="menus">
        <li>博客园</li>
        <li>首页</li>
        <li>新随笔</li>
        <li>联系</li>
        <li>管理</li>
      </ul>
      <ul class="details">
        <li>随笔-37</li>
        <li>文章-0</li>
        <li>评论-18</li>
      </ul>
    </div>
    <div class="content">
      <ul class="articles">
        <li v-for="item in obj.list" :key="item.id">
          <p class="title">{{item.title}}</p>
          <p class="tips">{{item.username}} {{item.date}} 阅读:120 评论:0</p>
        </li>
        <el-pagination
        class="pagination"
      :page-size="10"
      layout="total, pager, next"
      next-text="下一页"
      @current-change="handleCurrentChange"
      :total="obj.total">
    </el-pagination>
      </ul>
      <aside class="aside">
        <div class="announce">公告</div>
        <ul class="user-details">
          <li>昵称：<a href="javascript:;">ArthurWong</a></li>
          <li>园龄：<a href="javascript:;">2年5个月</a></li>
          <li>粉丝：<a href="javascript:;">23</a></li>
          <li>关注：<a href="javascript:;">0</a></li>
          <li><a href="javascript:;">+加关注</a></li>
        </ul>
        <div id="calen"></div>
        <div class="announce">常用链接</div>
        <ul class="user-details">
          <li><a href="javascript:;">我的随笔</a></li>
          <li><a href="javascript:;">我的评论</a></li>
          <li><a href="javascript:;">我的参与</a></li>
          <li><a href="javascript:;">最新评论</a></li>
          <li><a href="javascript:;">我的标签</a></li>
        </ul>
        <div class="announce">最新随笔</div>
        <ul class="user-details">
          <li v-for="(item,index) in obj.list" :key="item.id"><a href="javascript:;">{{index+1}}.{{item.title}}</a></li>
        </ul>
      </aside>
    </div>
    <div id="footer_bottom" class="text-center" style="display: block;background:#fff">
      <div>
        <a href="//www.cnblogs.com/AboutUS.aspx" class="d-none d-md-inline"
          >关于博客园</a
        >
        <a href="//www.cnblogs.com/ContactUs.aspx" class="d-none d-md-inline"
          >联系我们</a
        >
        ©2004-2021<a href="//www.cnblogs.com/">博客园</a>
        <span class="d-none d-md-inline">保留所有权利</span>
        <span id="powered_by">Powered by .NET Core on Kubernetes</span>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      obj: {},
      page: 1
    }
  },
  methods: {
    getLists() {
      this.$http.get('/main/article/show',{
        params: {
          page: this.page
        }
      }).then(res => {
        if (
                (res.status >= 200 && res.status < 300) ||
                res.status === 304
              ) {
                if (res.data.list.length>0 ) {
                  this.obj = res.data
                } else {
                  this.$message.error('出错了');
                }
              } else {
                this.$message.error(res.statusText);
              }
      })
    },
    handleCurrentChange(val) {
      this.page = val
      this.getLists()
    }
  },
  mounted() {
    new calendar('calen');
    this.getLists()
  }
};
</script>

<style scoped>
.home {
  height: 100vh;
}
.header {
  height: 146px;
  background-color: #2175bc;
  padding: 30px 15px;
  box-sizing: border-box;
  color: #fff;
  position: relative;
}
.user-name {
  margin: 0;
  font-weight: 400;
  padding: 0;
}
.words {
  margin: 0;
}
.menus {
  list-style: none;
  display: flex;
  padding: 0;
}
.menus li {
  margin-right: 65px;
  cursor: pointer;
}
.details {
  list-style: none;
  display: flex;
  position: absolute;
  right: 0;
  bottom: 0px;
  right: 10px;
}
.details li {
  margin-right: 10px;
  font-size: 13px;
  font-weight: 200;
  cursor: pointer;
}
.content {
  display: flex;
}
.articles {
  min-height: calc(100vh - 200px);
  flex: 1;
  list-style: none;
  background-color: #fff;
  margin-top: 5px;
  border-radius: 5px;
  padding: 0 15px 0 30px;
  box-shadow: 0 0 8px #999;
}
.articles .title {
  margin-top: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
  cursor: pointer;
}
.articles .tips {
  text-align: right;
  position: absolute;
  right: 0;
  bottom: 0px;
  font-size: 13px;
  color: #606266;
}
.articles li {
  height: 120px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
  border-bottom: 1px dashed #eee;
}
.aside {
  width: 260px;
  padding: 20px 60px 0 15px;
  box-sizing: border-box;
}
#footer_bottom {
  position: relative;
  padding: 15px 0;
  bottom: 0;
}
.announce {
  border-bottom: 1px dashed #ccc;
  padding: 10px 0;
  font-weight: 600;
}
.aside a {
  color: #3494fc;
  text-decoration: none;
}
.user-details {
  list-style: none;
  padding-left: 0;
  font-size: 13px;
}
.pagination {
  margin-top: 15px;
  margin-bottom: 15px;
  float: right;
}
.pagination >>> .el-pager li {
  border: 1px solid #39f;
  min-width: 28px;
  margin-right: 5px;
  color: #39f;
}
.pagination >>> .el-pager li.active {
  border: none;
  color: #000;
}
.pagination >>> .btn-next span {
  border: 1px solid #39f;
  padding: 0 8px;
  margin-left: -10px;
  color: #39f;
}
</style>
